package main

import (
	"fmt"
	"time"
)

var chs chan int = make(chan int, 1)

func main() {
	go write()
	read()
	//done := make(chan bool, 1)
	//go worker(done)
	//<-done
}

func write() {
	time.Sleep(3 * time.Second)
	chs <- 1
}

func read() {
	select {
	case ch1 := <-chs:
		fmt.Println(ch1)
		return

	case <-time.After(time.Second):
		fmt.Println("read time out")
		return
	}
}

func worker(done chan bool) {
	fmt.Println("working...")
	time.Sleep(time.Second)
	fmt.Println("done")
	done <- true
}
